package com.hesicare.health.service.impl;

import com.hesicare.health.entity.SysUserDept;
import com.hesicare.health.mapper.SysUserDeptMapper;
import com.hesicare.health.service.ISysUserDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 55097
 */
@Service
public class SysUserDeptServiceImpl implements ISysUserDeptService {

    @Autowired
    private SysUserDeptMapper sysUserDeptMapper;

    @Override
    public List<Long> getSysUserDeptByUserId(Long userId) {
        List<Long> sysUserDept = null;
        if (userId != null) {
            sysUserDept = sysUserDeptMapper.selectDeptIdByUserId(userId);
        }
        return sysUserDept;
    }

    @Override
    public SysUserDept getSysUserDept(SysUserDept sysUserDept) {
        SysUserDept userDept = null;
        if (sysUserDept != null) {
            userDept = sysUserDeptMapper.selectBySysUserDept(sysUserDept);
        }
        return userDept;
    }

    @Override
    public void insertSysUserDept(SysUserDept sysUserDept) {
        sysUserDeptMapper.inserUserDept(sysUserDept);
    }

    @Override
    public void insertSysUserDept(List<SysUserDept> sysUserDept) {
        sysUserDeptMapper.batchUserDept(sysUserDept);
    }

    @Override
    public void deleteSysUserDept(SysUserDept sysUserDept) {
        sysUserDeptMapper.deleteUserDeptByUserId(sysUserDept.getUserId());
    }
}
